/*****************************************************************************
*
*  PROJECT:		
*               
*  LICENSE:		
*
*  DEVELOPER:	
*
*****************************************************************************/

#include "EonVector3.h"

// comparison
bool Eon::Vector3::operator== ( Eon::Vector3& vec)
{
	return (x == vec.x && y == vec.y && z == vec.z);
}

// negation
Eon::Vector3 Eon::Vector3::operator- ()
{
	return Eon::Vector3(0-x, 0-y, 0-z);
}

// assignment
const Eon::Vector3& Eon::Vector3::operator= ( const Eon::Vector3& vec )
{
	x = vec.x;
	y = vec.y;
	z = vec.z;
	return *this;
}

// addition
const Eon::Vector3& Eon::Vector3::operator+= ( const Eon::Vector3& vec )
{
	x += vec.x;
	y += vec.y;
	z += vec.z;
	return *this;
}
	
// subtraction
const Eon::Vector3& Eon::Vector3::operator-= ( const Eon::Vector3& vec)
{
	x -= vec.x;
	y -= vec.y;
	z -= vec.z;
	return *this;
}

// scaling up
const Eon::Vector3& Eon::Vector3::operator*= ( const float& fScale )
{
	x *= fScale;
	y *= fScale;
	z *= fScale;
	return *this;
}

// scaling down
const Eon::Vector3& Eon::Vector3::operator/= ( const float& fScale )
{
	x /= fScale;
	y /= fScale;
	z /= fScale;
	return *this;
}
	
// addition w/o modification
const Eon::Vector3 Eon::Vector3::operator+ ( const Eon::Vector3& vec ) const
{
	return Eon::Vector3(x+vec.x, y+vec.y, z+vec.z);
}
	
// subtract w/o modification
const Eon::Vector3 Eon::Vector3::operator- ( const Eon::Vector3& vec ) const
{
	return Eon::Vector3(x-vec.x, y-vec.y, z-vec.z);
}

// scaling up w/o modification
const Eon::Vector3 Eon::Vector3::operator* ( const float& fScale ) const
{
	return Eon::Vector3(x*fScale, y*fScale, z*fScale);
}

// scaling down w/o modification
const Eon::Vector3 Eon::Vector3::operator/ ( const float& fScale ) const
{
	return Eon::Vector3(x/fScale, y/fScale, z/fScale);
}

// dot product
const float Eon::Vector3::dot ( const Eon::Vector3& vec ) const
{
	return (x*vec.x, y*vec.y, z*vec.z);
}
	
// vector length
const float Eon::Vector3::length() const
{
	return ( sqrt(x*x + y*y + z*z) );
}
	
// unit vector
const Eon::Vector3 Eon::Vector3::unit() const
{
	float fTemp = length();
	return Eon::Vector3(x/fTemp, y/fTemp, z/fTemp);
}

// normalize - make this vector a unit vector
void Eon::Vector3::normalize ( void )
{
	float fTemp = length();
	x /= fTemp;
	y /= fTemp;
	z /= fTemp;
}

// update this vector
void Eon::Vector3::update ( const Eon::Vector3& vec )
{
	x = vec.x;
	y = vec.y;
	z = vec.z;
}

void Eon::Vector3::update ( float fX, float fY, float fZ )
{
	x = fX;
	y = fY;
	z = fZ;
}